/**
 * @Author: zkz
 * @Date: 2025-09-26 15:22:28
 * @Discription: 图表组件核心代码模块
 */
import * as echarts from 'echarts';
import { useEffect,useRef } from 'react';
/**
 * 柱状图组件
 * @returns 渲染图表
 */
const BarChart = ({title,data,value}) => {
    const chartRef = useRef(null);
	useEffect(() => {
		const chartDom = chartRef.current;
		const myChart = echarts.init(chartDom);
		const option = {
            title:{
                text: title,
            },
			xAxis: {
				type: 'category',
				data: data
			},
			yAxis: {
				type: 'value'
			},
			series: [
				{
					data: value,
					type: 'bar'
				}
			]
		};
		option && myChart.setOption(option);
	}, []);
   return <div ref={chartRef} style={{ width: '500px', height: '500px' }} />
}

export default BarChart;